package com.lxu.report.service;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class YwReportDataService {

    @Resource
    private JdbcTemplate jdbcTemplate;

    /**
     * 查询通用的模板编号，原始设计方案，根据主体类型和立项来源，查询对应的模板编号
     * @param projDetailId
     * @param templateTypeCode
     * @return
     */
    public String findCommonTemplateCode(String projDetailId, String templateTypeCode) {
        String strSql ="SELECT t.template_code FROM report_template_config t\n" +
                "\t\tWHERE\n" +
                "            t.applicant_type=(SELECT ps.applicant_type FROM yw_proj_size ps,yw_proj_detail pd WHERE ps.id=pd.proj_size_id AND pd.id=?)\n" +
                "        AND t.apply_type_code=(SELECT t2.apply_type FROM yw_snaps_cust t2 WHERE t2.proj_detail_id=?)\n" +
                "        AND t.template_type_code=?";
        return  jdbcTemplate.queryForObject(strSql,new Object[]{projDetailId,projDetailId,templateTypeCode},String.class);
    }
}
